package com.fage.swing;

import javax.swing.*;
import java.awt.*;

/**
 * @author lin
 * @version 1.0
 * @date 2020-08-31 16:31
 * @Description TODO
 */
public class FrameMain2 {
    FrameMain1 f1 ;

    public FrameMain2() {
    }

    public FrameMain2(FrameMain1 f1) {
        this.f1 = f1;
    }

    public static void main(String[] args) {
        new FrameMain2().init();
    }

    public void init() {
        JFrame jFrame = new JFrame("FrameMain1");
        // 设置 可见性
        jFrame.setVisible(true);
        jFrame.setBackground(Color.BLUE);
        jFrame.setBounds(777, 377, 377, 277);

        Container contentPane = jFrame.getContentPane();

        contentPane.setLayout(null);

        Button bu1 = new Button("bu1");
        Button bu2 = new Button("bu2");
        bu1.setBounds(15, 60, 150, 150);
        bu2.setBounds(180, 60, 150, 150);
        bu1.setBackground(Color.pink);
        bu2.setBackground(Color.pink);
        bu1.addActionListener(e -> {
            System.out.println("e.getID() = " + e.getID());
            System.out.println("e = " + e);
            System.out.println("e.getActionCommand() = " + e.getActionCommand());
            f1.status=true;
            f1.glassPane.revalidate();
            f1.textArea.setText("1231231");
            f1.textArea.repaint();
            jFrame.dispose();
        });

        contentPane.add(bu1);
        contentPane.add(bu2);

        // 关闭事件
        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    }


}
